package algorithms.que11;

import java.util.ArrayList;
import java.util.List;

public class Request {
    public static void main(String[] args) {
        List<Integer> objects = new ArrayList<>();
        List<Thread> requests = new ArrayList<>();
        List<Integer> prepared = new ArrayList<>();

        for (int i = 0; i < 10; i++) {
            requests.add(new Thread(()->{
                objects.add(1);

            }));
        }
        requests.forEach(Thread::start);
        new Thread(()->{
            while (true){
                if(objects.size() > 3){
                    prepared.addAll(objects);
                    objects.removeAll(prepared);

                }
            }
        }).start();
        new Thread(()->{
            while (true){
                System.err.println(prepared.size());
            prepared.clear();}
        }).start();


    }
}
